var CommonMixin = {
	data: function() {
		return {}
	},
	onLoad() {},
	mounted() {},
	created() {},
	destroyed() {},
	onUnload() {},
	onUpdate() {},
	methods: {
		// 组件实例触发pageShow
		_refPageShow(name) {
			let triggerFn = () => {
				if (this.$refs[`${name}`]) {
					this.$refs[`${name}`]._triggerPageShow();
				}
			}
			// #ifdef MP-WEIXIN
			this.$nextTick(() => {
				triggerFn();
			})
			// #endif
			// #ifndef MP-WEIXIN
			setTimeout(() => {
				triggerFn();
			}, 300)
			// #endif
		},
		// 组件实例触发pageHide
		_refPageHide(name) {
			if (this.$refs[`${name}`]) {
				this.$refs[`${name}`]._triggerPageHide();
			}
		},
		// 显示操作菜单
		_showActionSheetPromise(param = {}) {
			return new Promise((resolve, reject) => {
				uni.showActionSheet({
					...param,
					success: (res) => {
						typeof param.success == 'function' && param.success(res);
						resolve(res)
					},
					fail: (err) => {
						typeof param.fail == 'function' && param.fail(err);
						reject(err)
					}
				})
			})
		},
		// 显示模态框
		_showModalPromise(param = {}) {
			return new Promise((resolve, reject) => {
				uni.showModal({
					...param,
					success: (res) => {
						typeof param.success == 'function' && param.success(res);
						resolve(res)
					},
					fail: (err) => {
						typeof param.fail == 'function' && param.fail(err);
						reject(err)
					}
				})
			})
		},
		// 显示Toast
		_showToastPromise(param = {}, errMode = false) {
			return new Promise((resolve, reject) => {
				uni.showToast({
					...param,
					icon: errMode ? 'none' : param.icon,
					success: (res) => {
						typeof param.success == 'function' && param.success(res);
						resolve(res)
					},
					fail: (err) => {
						typeof param.fail == 'function' && param.fail(err);
						reject(err);
					}
				})
			})
		}
	}
}
module.exports = CommonMixin;